# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
pkgname=sdl2
pkgver=2.0.6
pkgrel=2
pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard (Version 2)"
arch=('i686' 'x86_64')
url="http://www.libsdl.org"
license=('MIT')
depends=('glibc' 'libxext' 'libxrender' 'libx11' 'libgl' 'libxcursor')
makedepends=('alsa-lib' 'mesa' 'libpulse' 'libxrandr' 'libxinerama' 'wayland' 'libxkbcommon'
             'wayland-protocols' 'ibus' 'fcitx' 'libxss')
optdepends=('alsa-lib: ALSA audio driver'
            'libpulse: PulseAudio audio driver')
source=("https://www.libsdl.org/release/SDL2-${pkgver}.tar.gz"{,.sig}
        ibus.diff)
sha512sums=('ad4dad5663834ee0ffbdca1b531d753449b260c9256df2c48da7261aacd9795d91eef1286525cf914f6b92ba5985de7798f041557574b5d978b8224f10041830'
            'SKIP'
            '78697993f2bd11193c1b4d69076f5162f4c76be13d4f1c3f84162163d4d7d9a887f9d9ece93ed3effdcadb8e0e46b4a88de51699f4654fb318309f20b47867d4')
validpgpkeys=('1528635D8053A57F77D1E08630A59377A7763BE6')

prepare() {
  mkdir build
  cd SDL2-$pkgver
  # Fix abort caused by unterminated varargs
  patch -Np1 -i ../ibus.diff
}

build() {
  cd build
  ../SDL2-$pkgver/configure --prefix=/usr \
    --enable-sdl-dlopen \
    --disable-arts --disable-esd --disable-nas \
    --enable-alsa --enable-pulseaudio-shared \
    --enable-video-wayland \
    --enable-ibus --enable-fcitx \
    --disable-rpath
  make
}

package() {
  cd build
  make DESTDIR="$pkgdir" install
  install -Dm644 ../SDL2-$pkgver/COPYING.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
